package com.open.capacity.sign.service.impl;

import com.open.capacity.sign.CronTrigger.BaseCronTrigger;
import org.quartz.Job;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import org.springframework.stereotype.Component;

import java.io.Serializable;


@Component
public class InitializingCronTrigger extends BaseCronTrigger implements Serializable {

    private static final long serialVersionUID = 1L;

    @Autowired
    private SchedulerFactoryBean schedulerFactoryBean;

    public InitializingCronTrigger() {
        init();
    }

    @Override
    public String getMyCronExpression() {
        return "0 0 1 * * ?";
//        return "0/20 * * * * ?";
    }

    @Override
    public Job getMyTargetObject() {
        return new ScheduledTask();
    }

    public void parse() {
        try {
            schedulerFactoryBean.getObject().pauseAll();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
